import { PompeiLang } from '../types';
import prayers from '/@/data/content.json';

export function useRosary() {
  return getPrayerObj('rosary');
}

export function usePompei(getstr: string) {
  return getPrayerObj(getstr);
}

export function getRosaryChinese() {
  return getPrayerObj('rosaryChinese');
}

export function getPompeiLang(): PompeiLang {
  return getPrayerObj('pompeiLang');
}

export function getDefaultTitle() {
  return getPrayerObj('defaultTitle');
}

export function getPrayerObj(getstr: string) {
  if (!getstr) return [];
  const getarr = getstr.indexOf('.') !== -1 ? getstr.split('.') : [getstr];
  return getarr.reduce((obj, item) => {
    return obj[item];
  }, prayers);
}
